{
  "ui": {{ (consul_node_role == 'server') | bool | to_json }},
  "bind_addr": "{{ ansible_host }}",
  "bootstrap_expect": {{ consul_servers | length }},
{% if ansible_system == 'Linux' %}
  "ca_file": "/etc/consul.d/ssl/ca-cert.pem",
  "cert_file": "/etc/consul.d/ssl/server.crt",
  "key_file": "/etc/consul.d/ssl/server.key",
{% else %}
  "ca_file": "c:\\PROGRAMDATA\\consul\\ssl\\ca-cert.pem",
  "cert_file": "c:\\PROGRAMDATA\\consul\\ssl\\server.crt",
  "key_file": "c:\\PROGRAMDATA\\consul\\ssl\\server.key",
{% endif %}
  "client_addr": "127.0.0.1 {{ ansible_default_ipv4.address }}",
{% if ansible_system == 'Linux' %}
  "data_dir": "{{ consul_path }}/consul",
{% else %}
  "data_dir": "c:\\PROGRAMDATA\\consul\\data",
{% endif %}
  "datacenter": "{{ consul_datacenter | lower }}",
  "dns_config": {
    "allow_stale": {{ consul_arg.dns_allow_stale | bool | to_json }},
    "max_stale": "{{ consul_arg.dns_max_stale }}",
    "service_ttl": {{ consul_dns_service_ttl | to_nice_json(indent=2) | indent(4,False) }}
  },
  "domain": "{{ consul_domain | lower }}",
  "enable_local_script_checks": {{ consul_arg.enable_local_script_checks | bool | to_json }},
  "enable_script_checks": {{ consul_arg.enable_script_checks | bool | to_json }},
  "enable_syslog": {% if ansible_system == 'Linux' %}{{ consul_arg.enable_syslog | bool | to_json }}{% else %}false{% endif %},
  "encrypt": "{{ consul_arg.encrypt }}",
  "encrypt_verify_incoming": {{ consul_arg.encrypt_verify_incoming | bool | to_json }},
  "encrypt_verify_outgoing": {{ consul_arg.encrypt_verify_outgoing | bool | to_json }},
  "http_config": {
    "use_cache": {{ consul_arg.use_cache | bool | to_json }},
    "response_headers": {
      "Access-Control-Allow-Origin": "*"
    }
  },
  "log_level": "{{ consul_arg.log_level }}",
  "node_id": "{{ ansible_hostname | to_uuid }}",
  "node_name": "{{ ansible_hostname | lower }}",
  "performance": {{ consul_performance | to_nice_json(indent=2) | indent(2,False) }},
  "ports": {
    "server": {{ consul_port_arg.server }},
    "http": {% if not consul_arg.https %}{{ consul_port_arg.http }}{% else %}-1{% endif %},
    "https": {% if consul_arg.https %}{{ consul_port_arg.http }}{% else %}-1{% endif %},
    "dns": {{ consul_port_arg.dns_interface }},
    "serf_lan": {{ consul_port_arg.serf_lan }},
    "serf_wan": {{ consul_port_arg.serf_wan }}
  },
  "raft_protocol": {{ consul_arg.raft_protocol }},
  "recursors": ["{{ '", "'.join(vars["consul_dns_recursors"]) }}"],
{% if consul_node_role == 'server' %}
  "retry_join": ["{{ consul_servers | list | join(":" + consul_port_arg.serf_lan + '", "') }}:{{ consul_port_arg.serf_lan }}"],
{% elif consul_node_role == 'client' %}
  "retry_join": ["{{ consul_join_servers | list | join(":" + consul_port_arg.serf_lan + '", "') }}:{{ consul_port_arg.serf_lan }}"],
{% endif %}
  "server": {{ (consul_node_role == 'server') | bool | to_json }},
  "verify_incoming": {{ consul_arg.verify_incoming | bool | to_json }},
  "verify_incoming_https": {{ consul_arg.verify_incoming_https | bool | to_json }},
  "verify_outgoing": {{ consul_arg.verify_outgoing | bool | to_json }},
  "verify_server_hostname": {{ consul_arg.verify_server_hostname | bool | to_json }}
}
